-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: support logging errors that do not contain a stack #457
fix: support logging errors that do not contain a stack #457
Conversation
Custom errors may not have their stack property set. Pino used to serialize undefined stack which created invalid JSON output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work
Since |
I’d prefer to keep it as a string, so that users would always decode a
string. Errors should really have the stack property.
Il giorno sab 21 lug 2018 alle 14:46 James Sumners <notifications@github.com>
ha scritto:
… Since null is valid JSON, wouldn't the more appropriate fix be to
serialize it as null if error.stack === undefined?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#457 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADL41FpcC7yy7QDx7jFQIHbfxT8B8owks5uIyKKgaJpZM4VYD76>
.
|
See #382 |
... I think we've made a mistake here. For the current implementation, due to coercion, there are seven ways in which there may not be a stack
Let's remove the silly ones and go to the ones where a user may be attempting something real:
What's the (likely) expectations in each case?
I should have spent more time reviewing this. I'm not sure what to do with this in v4, but in v5 we need to be more thoughtful in how we approach this. |
You understand the problem now :) |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #456
Custom errors may not have their stack property set.
Pino used to serialize undefined stack which created invalid JSON output
Given the following contrived example:
Would output:
This is invalid JSON due to the
"stack":undefined
at the end of that output line.This PR adds a fix to avoid logging the stack if it is not set. So the above code now outputs: